﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Entity;

namespace IRepository
{
    public interface IInventoryRepository
    {
        // 库存主表操作
        Task<List<InventoryEntity>> GetByWarehouseAndProductAsync(int warehouseId, string productCode);
        Task<List<InventoryEntity>> GetByWarehouseAndProductAsync(int warehouseId, string productCode, IDbTransaction transaction);
        Task UpdateAsync(InventoryEntity entity);
        Task UpdateAsync(InventoryEntity entity, IDbTransaction transaction);
        Task AddAsync(InventoryEntity entity);
        Task AddAsync(InventoryEntity entity, IDbTransaction transaction);
        Task LockWarehouseAsync(string warehouseName);

        // 盘点明细操作
        Task AddInventoryDetailsAsync(int listId, List<InventoryDetailsEntity> details);
        Task UpdateInventoryDetailAsync(InventoryDetailsEntity detail);
        Task<List<InventoryDetailsEntity>> GetInventoryDetailsByListIdAsync(int listId);
        Task DeleteInventoryDetailAsync(int detailId);

        /// <summary>
        /// 检查仓库是否锁定
        /// </summary>
        Task<bool> CheckWarehouseLockAsync(string warehouseName);

        // 修复：移除重复的方法声明，只保留一个统一的方法
        Task<Dictionary<string, int>> GetBatchStockByProductCodesAsync(
            List<string> productCodes,
            int? warehouseId = null);

        // 可选：如果需要单独的方法，可以添加这个（但建议使用上面的统一方法）
        // Task<Dictionary<string, int>> GetStockByProductCodesAndWarehouseIdAsync(
        //     List<string> productCodes,
        //     int warehouseId);
        Task<Dictionary<string, int>> GetBatchStockByProductCodesAsync(
    List<string> productCodes,
    int? warehouseId = null,
    string location = null);
    }
}